package com.hemaapp.yjnh.view;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;

import com.hemaapp.yjnh.R;
import com.hemaapp.yjnh.activity.GuideActivity;
import com.hemaapp.yjnh.adapter.GuideAdapter;

/**
 * 类描述：新手指南dialog
 * 创建人：GuiyouZhang
 * 创建时间：2016/7/20 16:44
 * 修改备注：
 */
public class GuideDialog {

    private Context mContext;
    private Dialog dialog;
    private TextView tvContent;

    public GuideDialog(Context context) {
        this.mContext = context;
    }

    public GuideDialog builder(String welcome) {
        View dialogview = LayoutInflater.from(mContext).inflate(R.layout.dialog_guide, null);
        dialog = new Dialog(mContext, R.style.CustomizeDialogStyle);
        dialog.setContentView(dialogview);
        dialog.setCanceledOnTouchOutside(true);
        dialog.setCancelable(true);
        tvContent = (TextView) dialogview.findViewById(R.id.tv_welcome);
        tvContent.setText(welcome);
        TextView tvOk = (TextView) dialogview.findViewById(R.id.tv_ok);
        tvOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                Intent it = new Intent(mContext, GuideActivity.class);
                mContext.startActivity(it);
            }
        });
        Window dialogWindow = dialog.getWindow();
        dialogWindow.setGravity(Gravity.CENTER);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.x = 0;
        lp.y = 0;
        lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        dialogWindow.setAttributes(lp);
        return this;
    }

    public void show() {
        dialog.show();
    }

    public void dismiss() {
        dialog.dismiss();
    }
}
